<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8" />
        <title>4_姓名案例-计算属性简写</title>
        <script type="text/javascript" src="../js/vue.js"></script>
    </head>
    <body>
        <div id="demo">
            <h1>我喜欢的姑娘，眉如青山。</h1>
            <input type="text" v-model="remark">
            <hr>
            姓: <input type="text" v-model="firstName"><br><br>
            名: <input type="text" v-model="lastName"><br><br>
            全名: <span>{{fullName}}</span>
        </div>
    </body>

    <script type="text/javascript">
        Vue.config.productionTip = false;

        new Vue({
            el: '#demo',
            data: {
                firstName: 'zhang',
                lastName: 'san',
                remark: '我喜欢的姑娘，眉如青山。'
            },
            computed: {
                fullName(){
                    console.log('fullName');
                    const {firstName,lastName} = this;
                    return firstName[0].toUpperCase() + firstName.slice(1) + '-' + lastName
                }
            }
        })
        
    </script>
</html>